<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <crudOperation :permission="permission">
        <el-button
          slot="left"
          class="filter-item"
          size="mini"
          type="primary"
          @click="crud.toDetail('wareBuyReturnDetail')"
        >
          新增
        </el-button>
        <el-button
          slot="left"
          class="filter-item"
          size="mini"
          type="success"
          :disabled="crud.selections.length !== 1"
          @click="crud.toDetail('wareBuyReturnDetail',crud.selections[0].id)"
        >修改
        </el-button>
      </crudOperation>
      <div >
        <el-form size="small" label-width="70px" v-formkey="{query:crud.toQuery}">
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="业务日期">
                <div class="flex flex-row">
                  <el-date-picker
                    v-model="query.startTime"
                    align="right"
                    unlink-panels
                    class="fl1"
                    format="yyyy - MM - dd "
                    value-format="yyyy-MM-dd"
                    default-value
                    range-separator=""
                    placeholder="开始日期"
                  />
                  <el-date-picker
                    v-model="query.endTime"
                    align="right"
                    unlink-panels
                    class="fl1"
                    format="yyyy - MM - dd "
                    value-format="yyyy-MM-dd"
                    default-value
                    range-separator=""
                    placeholder="结束日期"
                  />
                </div>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="单据编码">
                <el-input  v-model="query.code"></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="供应商">
                <zSelect :value.sync="query.customerId" url="api/dropDown/basCustomerList" style="width:  100%;"/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="出库仓库">
                <zSelect :value.sync="query.warehouseId"  url="api/dropDown/basWarehouseList"
                         style="width:  100%"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10" style="text-align: center">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="状态">
                <el-select
                  v-model="query.orderStatus"
                  class="filter-item"
                  clearable
                  placeholder="状态"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    v-for="item in dict.common_order_status"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="采购渠道">
                <el-select
                  v-model="query.buyChannel"
                  class="filter-item"
                  clearable
                  placeholder="状态"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    v-for="item in dict.t_buy_order_buy_channel"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="商品">
                <table-select
                  :tableColumns="[{prop:'goodsCode',label:'商品编码',width:'100'},{prop:'goodsName',label:'商品名称',width: '280'}]"
                  labelKey="goodsName"
                  valueKey="goodsId"
                  :value.sync="query.goodsIds"
                  placeholder="请选择商品"
                  url="/api/dropDown/basGoodsListForAdd"
                ></table-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="备注">
                <el-input v-model="query.remark" />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <rrOperation :crud="crud"/>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <vue-context-menu :contextMenuData="contextMenuData"
                        @tableConfig="tableConfig"
                        @deletedata="deletedata"></vue-context-menu>

      <el-dialog title="表格配置"
                 :visible.sync="tableConfigShow"
                 width="60%">
        <j-table-column-config :columns.sync="crud.header"  @tabSave="tabSave" @pit="pit" />
      </el-dialog>
      <el-table ref="table"  border
                height="700"
                v-if="isShowTable"
                @header-dragend="changeColWidth"
                @contextmenu.native="showMenu"
                show-summary
                @cell-dblclick="row=>crud.toEdit(row)"
                v-loading="crud.loading"
                :data="crud.data"
                size="small"
                style="width: 100%;"
                :summary-method="crud.sumRow"
                @row-click="crud.selectRow"
                :row-style="crud.rowClass"
                :row-class-name="crud.tableRowClassName"
                @selection-change="crud.selectionChangeHandler"
                @row-dblclick="row=>setQuery(row.id)">
        <el-table-column :render-header="crud.renderHeader" type="selection" width="60" />
        <el-table-column :render-header="crud.renderHeader" type="index" width="60" label="序号"/>
        <el-table-column

          v-if="item.visible"
          v-for="(item, index) in crud.header"
          :key="`col_${index}`"
          :prop="item.prop"
          :label="columnLabel(item)"
          :width="item.width + 'px'"
          :data-porp='item.prop'
          @contextmenu.native="showMenu"
          @header-dragend="changeColWidth"
        >
          <!-- 自定义渲染模版 -->
          <template slot-scope="scope">
            <!-- 当列key为 sort 时，渲染一个手柄icon -->
            <template v-if="item.prop =='sort'">
              <div class="handle_move">
                <i :class="scope.row['sort']" />
              </div>
            </template>
            <template v-else>
              <span v-if="item.type == 1" style="margin-left: 10px">{{scope.row[`${item.prop}`]}}</span>
              <span v-if="item.type == 2" style="margin-left: 10px">{{ parseTime(scope.row[`${item.prop}`])}}</span>
              <span v-if="item.type == 3" style="margin-left: 10px">{{ getDict(`this.dict.label.${item.dictionary}["${scope.row[item.prop]}"]`) }}</span>
            </template>
          </template>
        </el-table-column>

        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('busDate')" prop="busDate" label="业务日期">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.busDate) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('code')" prop="code" label="单据编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerCode')" prop="customerCode" label="供应商编码" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerName')" prop="customerName" label="供应商名称" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerAreaName')" prop="customerAreaName" label="供应商区域" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('customerTypeName')" prop="customerTypeName" label="供应商分类" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('warehouseName')" prop="warehouseName" label="出库仓库" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('buyChannel')" prop="buyChannel" label="采购渠道" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.t_buy_order_buy_channel,scope.row.buyChannel) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->

<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('orderStatus')" prop="orderStatus" label="状态" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.common_order_status,scope.row.orderStatus) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('taxAmount')" prop="taxAmount" label="含税金额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('noTaxAmount')" prop="noTaxAmount" label="未税金额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('tax')" prop="tax" label="税额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceType')" prop="sourceType" label="来源类型" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.t_ware_buy_return_source_type,scope.row.sourceType) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceCode')" prop="sourceCode" label="来源单据号"></el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('count')" prop="count" label="条数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('boxCount')" prop="boxCount" label="箱数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('discountAmount')" prop="discountAmount" label="折扣金额" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('groundUserName')" prop="groundUserName" label="上架人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isPrint')" prop="isPrint" label="是否打印" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.common_yes_or_no,scope.row.isPrint) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isContact')" prop="isContact" label="是否来往" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.common_yes_or_no,scope.row.isContact) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('printCount')" prop="printCount" label="打印次数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('remark')" prop="remark" label="备注" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createUserName')" prop="createUserName" label="添加人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createTime')" prop="createTime" label="添加时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.createTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateUserName')" prop="updateUserName" label="修改人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateTime')" prop="updateTime" label="修改时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.updateTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditUserName')" prop="auditUserName" label="审核人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditTime')" prop="auditTime" label="审核时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.auditTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeUserName')" prop="closeUserName" label="关闭人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeTime')" prop="closeTime" label="关闭时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.closeTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-permission="['admin','wareBuyEnter:edit','wareBuyEnter:del']" label="操作" width="150px" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <udOperation-->
<!--              :data="scope.row"-->
<!--              :permission="permission"-->
<!--            />-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>



    <el-dialog  title="搜索"
                :before-close="handleClose"
                destroy-on-close
                v-dialogDrag
                close-on-press-escape
                width="80%"
                :visible.sync="!crud.props.searchToggle" >
      <el-form size="small" label-width="70px">
        <el-row :gutter="10">
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="业务日期">
              <el-date-picker
                v-model="query.dataExtent"
                type="daterange"
                @change="getValue()"
                align="right"
                unlink-panels
                style="width: 100%"
                format="yyyy - MM - dd "
                value-format="yyyy-MM-dd"
                default-value
                range-separator=""
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="单据编码">
              <el-input  v-model="query.code"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="供应商">
              <zSelect :value.sync="query.customerId" url="api/dropDown/basCustomerList" style="width:  100%;"/>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="供应商分类">
              <JtgTree
                v-model="query.customerTypeId"
                :initValue="query.customerTypeName"
                :keyword="query.customerTypeName"
                url="basCustomerTypeTree"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="供应商区域" prop="customerAreaId">
              <JtgTree
                v-model="query.customerAreaId"
                :initValue="query.customerAreaName"
                :keyword="query.customerAreaId"
                url="basCustomerAreaTree"
              />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="出库仓库">
              <zSelect :value.sync="query.warehouseId"  url="api/dropDown/basWarehouseList"
                       style="width:  100%"/>
            </el-form-item>
          </el-col> <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
          <el-form-item label="采购部门">
            <zSelect :value.sync="query.deptId"   url="api/dropDown/childSysDeptList"
                     style="width:  100%"/>
          </el-form-item>
        </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="采购人员" prop="userId">
              <zSelect :value.sync="query.userId"   url="api/dropDown/sysUserList" :params="{deptId:query.deptId}"
                       style="width:  100%"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="来源类型">
              <el-select v-model="query.sourceType" style="width:  100%"  class="edit-input" placeholder="请选择来源类型" >
                <el-option
                  v-for="(item,index) in dict.t_ware_buy_return_source_type"
                  :key="index"
                  v-if="item.seq>0"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="是否打印">
              <el-select v-model="query.isPrint"      style="width:  100%" class="edit-input" placeholder="请选择打印状态" >
                <el-option
                  v-for="(item,index) in dict.common_yes_or_no"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="状态">
              <el-select
                v-model="query.orderStatus"
                class="filter-item"
                clearable
                placeholder="状态"
                size="small"
                style="width: 100%"
                @change="crud.toQuery"
              >
                <el-option
                  v-for="item in dict.common_order_status"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="采购渠道">
              <el-select
                v-model="query.buyChannel"
                class="filter-item"
                clearable
                placeholder="状态"
                size="small"
                style="width: 100%"
                @change="crud.toQuery"
              >
                <el-option
                  v-for="item in dict.t_buy_order_buy_channel"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="制单人">
              <el-input v-model="query.createUserName" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="备注">
              <el-input v-model="query.remark" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="单据说明">
              <el-input v-model="query.orderRemark" />
            </el-form-item>
          </el-col>

        </el-row>
        <el-row :gutter="10" style="text-align: center">
          <!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
          <el-button class="filter-item"  size="mini" type="primary" @click="toQuery">搜索</el-button>
          <el-button class="filter-item" plain   size="mini" type="primary"
                     @click="crud.resetQuery()">重置</el-button>
          <!--            </el-col>-->
        </el-row>
      </el-form>
    </el-dialog>
    <el-dialog  title="打印预览"
                destroy-on-close
                v-dialogDrag
                close-on-press-escape
                :visible.sync="showPdf" append-to-body width="50vw">
      <j-pdf :src="pdfSrc" ></j-pdf>
    </el-dialog>
    <el-dialog
      title="请选择打印模板"
      :visible.sync="crud.printConfig.pringDialog"
      width="30%"
    >
      <jPrintConfig groupId="wareBuyReturn"
                    v-if="crud.printConfig.pringDialog"
                    @getPrintId="crud.toPrint"
                    :isPreview="crud.printConfig.isPreview"
      ></jPrintConfig>
    </el-dialog>
  </div>
</template>

<script>
import crudWareBuyEnter from '@/api/erp/wareBuyReturn'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import Treeselect from '@riophae/vue-treeselect'
import { getTypeList } from '@/api/erp/basGoodsType'
import { getAreaTree } from '@/api/erp/basCustomerArea'
import crudBuyOrder from '@/api/erp/buyOrder'
import JtgTree from "@/components/Tree/JtgTreePlus";
import {tablemixins} from "@/mixins/tablemixins";
import jTableColumnConfig from "@/components/jTableColumnConfig/jTableColumnConfig";
import { publicListKey } from "@/utils/key";
import jPrintConfig from '@/components/jPrintConfig/jPrintConfig'
import {getWareBuyReturnPreviousNextPageIdList} from "../../../api/erp/wareBuyReturn";
// crud交由presenter持有
const defaultCrud = CRUD({ title: '采购退货出库单',name:'wareBuyReturn', url: 'api/wareBuyReturn', sort: 'id,desc', optShow: {
    add: false,
    edit: false,
    del: false,
    copy: true,
    download: true,
    leadingIn: true,
    enable: false,
    disable: false,
    reject: true,
    pass: true,
    print: true,
    printDetail: true,
    invalid: true,
    recover: true
  }, crudMethod: { ...crudWareBuyEnter }})
const defaultForm = { id: null, code: null, name: null, type: null, busDate: null, sourceType: null, sourceId: null, sourceCode: null, isAppend: null, serialNumber: null, buyChannel: null, customerOrderCode: null, customerId: null, customerCode: null, customerName: null, isContact: null, customerAreaId: null, customerAreaCode: null, customerAreaName: null, customerTypeId: null, customerTypeCode: null, customerTypeName: null, deptId: null, deptCode: null, deptName: null, userId: null, userCode: null, userName: null, warehouseId: null, warehouseCode: null, warehouseName: null, count: null, boxCount: null, taxAmount: null, noTaxAmount: null, tax: null, discountAmount: null, isDraw: null, drawDate: null, cancelStatus: null, cancelDate: null, cancelAmount: null, unCancelAmount: null, groundUserId: null, groundUserIds: null, groundUserCode: null, groundUserName: null, isPrint: null, printCount: null, seq: null, orderStatus: null, remark: null, orderRemark: null, createUserId: null, createUserCode: null, createUserName: null, createTime: null, updateUserId: null, updateUserCode: null, updateUserName: null, updateTime: null, auditUserId: null, auditUserCode: null, auditUserName: null, auditTime: null, closeUserId: null, closeUserCode: null, closeUserName: null, closeTime: null }
export default {
  name: 'wareBuyReturn',
  components: { pagination, crudOperation, rrOperation, udOperation,Treeselect,JtgTree, jTableColumnConfig, jPrintConfig },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud(), tablemixins, publicListKey],
  dicts: ['common_yes_or_no',
    'common_order_status',
    't_ware_buy_return_source_type',
    't_buy_order_buy_channel',
    't_ware_buy_return_type',
    'common_cancel_status',
    't_ware_buy_return_buy_channel',
    't_bas_customer_is_contact'
  ],
  data() {
    return {
      typeList:[],
      areaList: [],
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      permission: {
        add: ['admin', 'wareBuyReturn:add'],
        edit: ['admin', 'wareBuyReturn:edit'],
        del: ['admin', 'wareBuyReturn:del'],
        import: ['admin', 'wareBuyReturn:import'],
        export: ['admin', 'wareBuyReturn:export'],
        copy: ['admin', 'wareBuyReturn:copy'],
        upload: ['admin', 'wareBuyReturn:upload'],
        download: ['admin', 'wareBuyReturn:download'],
        pass: ['admin', 'wareBuyReturn:pass'],
        reject: ['admin', 'wareBuyReturn:reject'],
        closed: ['admin', 'wareBuyReturn:closed'],
        invalid: ['admin', 'wareBuyReturn:invalid'],
        stop: ['admin', 'wareBuyReturn:stop'],
        recover: ['admin', 'wareBuyReturn:recover'],
      },
      orderList: [],

      rules: {
      }    }
  },
  watch: {
  },
  created() {
    this.getAreaList()
    this.getTypeList()
  },

  updated() {
    this.$nextTick(() => {
      this.$refs.table.doLayout()
    })
  },
  methods: {
    toQuery(){
      this.crud.props.searchToggle = !this.crud.props.searchToggle
      this.crud.toQuery()
    },
    setQuery(id){
      getWareBuyReturnPreviousNextPageIdList({...this.query,id,...this.crud.page,sort:this.query.sort || this.crud.sort}).then(res=>{
        const idDate = Date.now().toString()
        sessionStorage.setItem(idDate,JSON.stringify(res.data))
        this.$router.push({ path:`wareBuyReturnDetail/${id}?idDate=${idDate}`})
      })

    },
    handleClose(){
      this.crud.props.searchToggle = !this.crud.props.searchToggle
    },
    getValue(e){
      this.query.startTime =this.query.dataExtent[0]
      this.query.endTime =this.query.dataExtent[1]
    },
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },
    getOrderInfo(id){
      let that = this
      that.crud.loadingOpen()
      crudWareBuyEnter.detail({id,size:9999,page:1}).then(res => {
        console.log('orderList', res)
        if(res.success){
          this.orderList = res.data.content
          that.crud.loadingClose()
        }else{
          that.crud.loadingClose()
          this.$message({
            message: res.msg,
            type: 'warning'
          })
        }

      }).catch((res)=>{
        that.crud.loadingClose()
      })
    },
    normalizer(node) {
      //去掉children=[]的children属性
      if (node.children == null || node.children.length == 0) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.name,
        children: node.children
      }
    },
    getAreaList() {
      getAreaTree().then(res => {
        this.areaList = res
      })
    },
    getTypeList() {
      getTypeList({page: 0, size: 999}).then(res => {
        this.typeList = res
      })
    },
  }
}
</script>

<style scoped>
.table-img {
  display: inline-block;
  text-align: center;
  background: #ccc;
  color: #fff;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  width: 32px;
  height: 32px;
  line-height: 32px;
}
</style>
